package com.dailyblue.java.cloud.sentinel.provider.controller;

import com.dailyblue.java.commons.util.JsonResult;
import com.dailyblue.java.commons.util.ResultTool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/provider")
@Slf4j
public class ProviderController {

    @GetMapping("/a")
    public JsonResult a() {
        String name = Thread.currentThread().getName();
        log.info("{},开始访问a方法！", name);
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("{},结束访问a方法！", name);
        return ResultTool.success(name);
    }

    @GetMapping("/b")
    public JsonResult b() throws Exception {
        String name = Thread.currentThread().getName();
        log.info("{},访问b方法！", name);
        return ResultTool.success(name);
    }
}
